# 父镜像
FROM zhaotao/base-centos7

RUN     \
        redisDownloadUrl=http://download.redis.io/releases/redis-5.0-rc4.tar.gz; \
        redisPath=/tmp/redis; \
        redisFileName=redis.tar.gz; \
        yum -y install wget gcc make; \
        wget -O $redisFileName $redisDownloadUrl; \
        mkdir -p $redisPath; \
        tar -zxf $redisFileName -C $redisPath --strip-components=1; \
        make -C $redisPath; \
        make -C $redisPath/src install; \
	\cp -f $redisPath/src/redis-sentinel /usr/local/bin; \
	# 允许远程访问
        sed -i 's/bind 127.0.0.1/bind 0.0.0.0/g' $redisPath/redis.conf; \
        # 允许后台运行
        sed -i 's/daemonize no/daemonize yes/g' $redisPath/redis.conf; \
	# 更改工作目录
	set -i 's/^\(dir .*\)$/# \1\ndir \/data/' $redisPath/redis.conf; \
        # 复制配置文件
        mkdir -p /etc/redis/; \
	\cp -f $redisPath/redis.conf /etc/redis/redis.conf; \
        # 清理
        yum -y remove wget gcc make; \
        yum clean all; \
        rm -rf $redisFileName; \
	rm -rf $redisPath*

WORKDIR /data

EXPOSE 6379

ENTRYPOINT redis-server /etc/redis/redis.conf && bash
